using UnityEngine;

public class INT_TalkingAnimation : MonoBehaviour
{
	public INT_Chat TargetChat;

	[SerializeField]
	private Animator TargetAnimator;

	[Header("Used for more basic NPCs, that don't usually move")]
	[SerializeField]
	private string TalkAnimationName;

	[SerializeField]
	private string IdleAnimationName;

	[Header("For more advanced NPCs like Papyrus or Toriel")]
	[SerializeField]
	private bool UseTalkBool;

	[SerializeField]
	private string TalkBoolName;

	private void Update()
	{
		if (TargetChat.CurrentlyBeingUsed)
		{
			if (TalkAnimationName != null && !UseTalkBool)
			{
				TargetAnimator.Play(TalkAnimationName);
			}
			if (TalkBoolName != null && UseTalkBool)
			{
				TargetAnimator.SetBool(TalkBoolName, true);
			}
		}
		else
		{
			if (IdleAnimationName != null && !UseTalkBool)
			{
				TargetAnimator.Play(IdleAnimationName);
			}
			if (TalkBoolName != null && UseTalkBool)
			{
				TargetAnimator.SetBool(TalkBoolName, false);
			}
		}
	}
}
